goog.provide('dkpoints.standings.Standings');

goog.require('dkpoints.standings.templates');
goog.require('dkpoints.status.Status');



/**
 * The object responsible for setting up the Standings List UI.
 * @param {Element} bodyContent The body_content element of the page.
 * @param {dkpoints.rpc.RPCService} rpc The RPC service for the app.
 * @param {dkpoints.status.Status} status The status panel.
 * @constructor
 */
dkpoints.standings.Standings = function(bodyContent, rpc, status) {
  /**
   * @type {Element}
   * @private
   */
  this.bodyContent_ = bodyContent;

  /**
   * @type {dkpoints.rpc.RPCService}
   * @private
   */
  this.rpc_ = rpc;

  /**
   * @type {dkpoints.status.Status}
   * @private
   */
  this.status_ = status;
};


/**
 * Display the Standings UI.
 * TODO:  This will eventually go to the server to retrieve the actual stats.
 * @return {dkpoints.standings.Standings} Return the object to allow for shorter
 *    calling code.
 */
dkpoints.standings.Standings.prototype.render = function() {
  document.title = 'DKPoints - DKP Standings';

  // Fake some Player DKP objects
  var raiders = [
    {rank: 1, plName: 'Russ', plClass: 'rogue', dkp: 25.6},
    {rank: 2, plName: 'Amaraz', plClass: 'paladin', dkp: 25.5}
  ];

  // Fake a lot more.
  for (var i = 2; i < 16; ++i) {
    raiders[i] = {
      rank: i,
      plName: 'Amaraz',
      plClass: 'paladin',
      dkp: Math.round(100000 * (25.5 - i - 0.3 * i)) / 100000
    };
  }

  var templateParams = {
    raiders: raiders
  };

  this.bodyContent_.innerHTML =
      dkpoints.standings.templates.dkpListing(templateParams);

  return this;
};


/**
 * Save state and tear down the UI.
 */
dkpoints.standings.Standings.prototype.dispose = function() {
  // No state to be saved, just clear the UI.
  this.bodyContent_.innerHTML = '';
};
